<div class="lib-edit">
    <div class="header" style="border:0;border-bottom:1px solid #dbdbdb;">
        <a href="javascript:void(0);" onclick="window.history.go(-1);"><i class="icons icons-back"></i> 文本内容编辑</a>
    </div>
    <div class="content">
        <div class="preview" style="margin-right:-5px;">
            <div class="cell" style="border-left:0;">
                <div class="lib-title" style="font-size:14px;border-bottom:1px dotted #cccccc;">
                    效果：
                </div>
                <div class="cover">
                    <img src="<{$APP_PATH}>/home/public/img/single-example.png" alt="" />
                </div>
            </div>
        </div>
        <div class="editor">
            <form id="text_form" method="post" onsubmit="javascript:return false;">
            <div class="cell">
                <div class="form-rule" role="form">
                    <div class="form-group">
                        <label>关键词<strong class="c-red">*</strong><span class="c-gray">（注:多个规则对应一条内容用逗号分隔。如：help ,帮助）</span></label>
                        <input name="str[keyword]" type="text" class="form-control" value="<{$infoRow.keyword}>">
                    </div>
                </div>
            </div>
            <div class="cell cell-dark">
                <div class="form-rule form-rule-add" role="form">
                    <div class="form-group">
                        <label>回复内容<strong class="c-red">*</strong></label>
                        <textarea name="str[info_intro]" maxlength="300" class="form-control" cols="20" rows="10"><{$infoRow.info_intro}></textarea>
                        <div class="reply-sub" style="padding-top:8px;">
                            <span class="c-gray">最多可以输入300字</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="cell cell-dark">
                <div class="form-rule" role="form">
                    <div class="form-group">
                        <label>状态<span class="c-gray"></span></label>
                        <br/>
                        <label><input type="radio" name="num[state]" <{if $infoRow.state!='2'}>checked<{/if}> value='1'> 开放</label>&nbsp;&nbsp; 
                        <label><input type="radio" name="num[state]" <{if $infoRow.state=='2'}>checked<{/if}> value='2'> 关闭</label>
                    </div>
                </div>
            </div>
            <div class="opt">
                <input type="hidden" name="num[id]" value="<{$infoRow.id}>" />
                <input type="hidden" name="a" value="add" />
                <input type="button" class="btn btn-large btn-success" value="完成" id="saveBtn" onclick="save(this)" />
            </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
function save(obj){
    if($("input[name='str[keyword]']").val()==''){
        note_info('请填写关键词',obj,'warn');return;
    }
    if($("textarea[name='str[info_intro]']").val()==''){
        note_info('请填写回复内容',obj,'warn');return;
    }
    
    //敏感词过滤
    var matchStrKey,matchStrContent,senseRow;
    var senseStrKeyword='';
    var senseStrContent='';
    if('<{$senseRow}>'){
        senseRow=$.parseJSON('<{$senseRow}>');
        $.each(senseRow,function(i,n){
            matchStrKey=$("input[name='str[keyword]']").val().match(n);
            matchStrContent=$("textarea[name='str[info_intro]']").val().match(n);
            if(matchStrKey) senseStrKeyword+='&nbsp;'+matchStrKey+'&nbsp;';
            if(matchStrContent) senseStrContent+='&nbsp;'+matchStrContent+'&nbsp;';
        });
        if(senseStrKeyword){
            note_info('关键词包含敏感词'+senseStrKeyword+'请更换',obj,'warn');return;
        }
        if(senseStrContent){
            note_info('回复内容包含敏感词'+senseStrContent+'请更换',obj,'warn');return;
        }
    }
    
    $.post('index.php',$('#text_form').serialize(),function(msg){
        msg=$.trim(msg);
        if(msg=='suc'){
            note_info('保存成功',obj);
            setTimeout("window.location.href='index.php'",1200);
        }else{
            note_info(msg,obj,'warn');
        }
    });
}
</script>